//
//  ZZCReadTableViewCell.m
//  B段项目
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "ZZCReadTableViewCell.h"

@interface ZZCReadTableViewCell ()

@property (nonatomic, retain)UILabel *titleLabel;
@property (nonatomic, retain)UILabel *contentLabel;
@property (nonatomic, retain)UIImageView *detailImage;

@end

@implementation ZZCReadTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(WIDTH / 20);
        make.top.mas_equalTo(HEIGHT / 40);
        make.width.mas_equalTo(WIDTH * 0.9);
        make.height.mas_equalTo(HEIGHT / 30);
    }];
    
    self.detailImage = [[UIImageView alloc] init];
    [self.contentView addSubview:self.detailImage];
    [self.detailImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(HEIGHT / 60);
        make.width.mas_equalTo(WIDTH * 0.4);
        make.height.mas_equalTo(HEIGHT / 7);
    }];
    
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.font = [UIFont systemFontOfSize:15];
    self.contentLabel.numberOfLines = 3;
    [self.contentView addSubview:self.contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.detailImage.mas_right).offset(WIDTH / 36);
        make.top.equalTo(self.detailImage.mas_top);
        make.width.mas_equalTo(WIDTH * 0.5);
        make.height.mas_equalTo(HEIGHT / 14);
    }];
    
}

- (void)setDetailListModel:(ZZCReadDetailModel *)detailListModel
{
    _detailListModel = detailListModel;
    
    self.titleLabel.text = self.detailListModel.title;
    [self.detailImage sd_setImageWithURL:[NSURL URLWithString:self.detailListModel.coverimg] placeholderImage:[UIImage imageNamed:@"zhanwei.jpg"]];
    self.contentLabel.text = self.detailListModel.content;
    
    [self.contentLabel sizeToFit];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
